﻿using Bootstrap.Security;
using System.Linq;

namespace CpsyV2Web.DataAccess
{
    /// <summary>
    /// 字典表
    /// </summary>
    public static class DictHelper
    {
        internal const string RetrieveCpsyDictsDataKey = "DictHelper-RetrieveCpsyDicts";

        /// <summary>
        /// 获取网站标题
        /// </summary>
        /// <returns></returns>
        public static string RetrieveTitle()
        {
            var dicts = BootstrapDict.RetrieveDicts();
            return (dicts.Where(d => d.Category == "云心理平台网站设置" && d.Name == "网站标题").FirstOrDefault() ?? new BootstrapDict() { Code = "云心理专家平台" }).Code;
        }

        /// <summary>
        /// 获取网站页脚
        /// </summary>
        /// <returns></returns>
        public static string RetrieveFooter()
        {
            var dicts = BootstrapDict.RetrieveDicts();
            return (dicts.Where(d => d.Category == "云心理平台网站设置" && d.Name == "网站页脚").FirstOrDefault() ?? new BootstrapDict() { Code = "版权所有：云心理实验室.技术支持：云心理实验室" }).Code;
        }

        /// <summary>
        /// 获取测试路径
        /// </summary>
        /// <returns></returns>
        public static string RetrieveTestPath()
        {
            var dicts = BootstrapDict.RetrieveDicts();
            return (dicts.Where(d => d.Category == "云心理平台网站设置" && d.Name == "网站路径").FirstOrDefault() ?? new BootstrapDict() { Code = "http://localhost:2780/" }).Code;
        }

        /// <summary>
        /// 获取测评题图片路径
        /// </summary>
        /// <returns></returns>
        public static string RetrieveIconFolderPath()
        {
            var dicts = BootstrapDict.RetrieveDicts();
            return (dicts.Where(d => d.Category == "云心理平台网站设置" && d.Name == "测试题图片地址").FirstOrDefault() ?? new BootstrapDict() { Code = "~/Content/images/exam/" }).Code;
        }

        /// <summary>
        /// 获取网站注销地址
        /// </summary>
        /// <returns></returns>
        public static string RetrieveLogoutUrl()
        {
            var dicts = BootstrapDict.RetrieveDicts();
            return (dicts.Where(d => d.Category == "云心理平台网站设置" && d.Name == "系统注销地址").FirstOrDefault() ?? new BootstrapDict() { Code = "#" }).Code;
        }
    }
}
